package com.zk.stock.controller;

import com.zk.stock.pojo.entity.SysUser;
import com.zk.stock.service.UserService;
import com.zk.stock.vo.resp.LoginRespVo;
import com.zk.stock.vo.resp.R;
import com.zk.stock.vo.resq.LoginReqVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author 曹自康的Laptop
 * @version 1.0
 * @Date 2024-06-2813:46
 */
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
@Api(tags = "用户相关接口处理器")
public class UserController {


    private final UserService userService;
    @ApiOperation(value = "根据用户名查询用户信息")
    @GetMapping("/user/{userName}")
    public SysUser getUserByUserName(@PathVariable("userName") String userName){
        SysUser byUserName = userService.findByUserName(userName);
        return byUserName;

    }

    @GetMapping("/list")
    public List<SysUser> listUsers(){
        return userService.findUserAllList();
    }
    @PostMapping("/login")
    public R<LoginRespVo> login(@RequestBody LoginReqVo vo){
        return userService.login(vo);

    }
    /*
    生成图片验证码功能
     */
    @GetMapping("/captcha")
    public R<Map> getCaptcha(){
        return userService.getCaptcha();
    }


}
